<template>
 <div class="login-area">
   <div class="login-form">
     <div class="login-title"  >
       <img src="" >
     </div>
     <div class="login-ipt">
       <div class="login-label name-label">
         <input type="text"  v-model="userName" placeholder="请输入账号"/>
       </div>
       <div class="login-label password-label">
         <input type="password" v-model="password" placeholder="请输入密码"
                v-on:keyup.enter="loginIn"/>
       </div>
     </div>
     <div class="login-btn">
       <button @click="loginIn">立即登录</button>
     </div>
     <blockquote></blockquote>
   </div>
 </div>
</template>

<script>
import md5 from 'js-md5'
export default {
  name: 'login',
  data () {
    return {
      userName: '',
      password: ''
    }
  },
  methods: {
    loginIn: function () {
      if (this.userName === '') {
        return false
      }
      if (this.password === '') {
        return false
      }
      let md5Data = md5(this.password).toUpperCase()
      this.$http.post('/server/login/loginByUP', {
        username: this.userName,
        password: md5Data
      }
      ).then(function (data) {
        if (this.userName === 'admin') {
          this.$router.push({path: '/admin'})
        } else {
          this.$router.push({path: '/home'})
        }
      })
    }
  }
}
</script>

<style scoped >
.login-area{
  position: relative;
  height: 100%;
  width: 100%;
  background-image: url(../assets/longDarkNight.jpg);
  background-repeat: no-repeat;
  background-size: 100% 100%;
}
@media screen and (max-width: 600px) {
  .login-area{
    background-image: url(../assets/darkNight.jpg);
  }
}
.login-form{
  position: absolute;
  top: 50%;
  left: 50%;
  margin-top: -10%;
  transform: translate(-50%, -50%);
}
.login-title{
  max-width: 100%;
}
.login-title>img{
  width: 100%;
}
.login-ipt{
  position: relative;
  padding: 10px;
  width: 235px;
  margin: 0 auto;
}
.login-ipt>.login-label{
  width: 200px;
  height: 40px;
  line-height: 40px;
  margin: 0 auto 10px;
  padding: 0 5px 0 30px;
  border-radius: 10px;
  background: #4caf50b8;
  /* -webkit-box-shadow: 1px -1px 5px #333 inset; */
  /* box-shadow: 1px -1px 5px #333 inset; */
  -webkit-transition-duration: 300ms;
  transition-duration: 300ms;
}
.login-ipt>.login-label:hover,
.login-ipt>.login-label:active{
  background: rgba(73, 153, 77, 0.72);
}
.login-label>input{
  width: 100%;
  height: 100%;
  padding: 0 10px;
  color: #fff;
  text-shadow: 1px 1px 1px rgba(0,0,0,.7);
  vertical-align: top;
  outline: none;
}

.login-label>input::-webkit-input-placeholder{
  color: #ffffff;
}
.name-label:before{
  content: url("../assets/icon-user.png");
  position: absolute;
  left: 20px;
}
.password-label:before{
  content: url("../assets/icon-lock.png");
  position: absolute;
  left: 20px;
}
.login-btn{
  height: 40px;
  padding: 0 10px;
  border-radius: 10px;
}
.login-btn>button{
  display: inherit;
  width: 235px;
  height: 100%;
  margin: 0 auto 10px;
  border-radius: 20px;
  border:none;
  color: #fff;
  text-shadow: 1px 1px 1px rgba(0,0,0,.7);
 /* box-shadow: 1px -1px 5px #333;*/
  background: #FF9800;
  cursor: pointer;
  transition-duration: 300ms;
  outline: none;
}
.login-btn>button:hover,
.login-btn>button:active{
  background: #ffff00;
}
</style>
